<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/17
 * Time: 17:38
 */

namespace app\zucai\admin;

use app\admin\controller\Admin;
use app\common\builder\ZBuilder;
use think\Db;

class Image extends Admin
{
    //首页展示图

    public function index(){
        if($this->request->isPost()){
            $date=Db::name('image')->where('id',1)->update(['path'=>$_POST['img']]);
            if ($date){
                $this->success('更新成功');
            }
            else{
                $this->error('更新失败');
            }
        }else{
            $image=Db::name('image')->where('id',1)->find();
            return ZBuilder::make('form')
                ->addFormItems([
                    ['image','img','首页展示图','',$image['path']],
                ])
                ->fetch();
        }

    }
}